import Cookies from 'js-cookie'
import axios from "axios";

let apiBaseUrl = window.apiBaseUrl
console.log(apiBaseUrl)


export function getCookies() {
    const name = Cookies.get('name')
    const pwd = Cookies.get('pwd')
    return {
        name, pwd
    }
}

export function setCookies(name, pwd) {
    Cookies.set('name', name, {expires: window.cooKieTime})
    Cookies.set('pwd', pwd, {expires: window.cooKieTime})
}

export function removeCookie() {
    Cookies.remove('name')
    Cookies.remove('pwd')
}

export async function getUserInfo(name) {
    let url = apiBaseUrl + '/userInfo?name=' + name
    let res = await axios.get(url)
    return res.data
}

export async function changePassword(name, pwd) {
    let url = apiBaseUrl + '/editPwd'
    let res =await axios.post(url, {name, pwd})
    return res.data
}
